package top.huntwolf.admin.pojo.orderEntity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import top.huntwolf.admin.common.enums.BookConditionEnum;
import top.huntwolf.admin.common.enums.EnumValue;
import top.huntwolf.admin.pojo.book.BuyBook;
import top.huntwolf.admin.pojo.book.SaleBook;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class OrderBook {

    private int num;
    private String isbn;
    private String orderId;

    private BookConditionEnum conditionEnum;

    private BuyBook buyBook;

    @JsonIgnore
    private SaleBook saleBook;


    public void setConditionEnum(Object condition){
        if (condition instanceof BookConditionEnum){
            conditionEnum = (BookConditionEnum) condition;
        }else{
            conditionEnum = EnumValue.valueOf(BookConditionEnum.class,condition);
        }
    }
}
